<template>
	<view class="login">
<!-- 		<view class="back">
			<template>
				<view>
					<u-navbar back-text="返回" title="登录"></u-navbar>
				</view>
			</template>
		</view> -->
		<view class="intro">
			<image src="/static/images/logo.png"></image>
			<view class="tips">
				一杯好茶，一口软欧包
				<br>
				在奈雪遇见两种美好
			</view>
		</view>
		<view class="bottom">
			<!-- #ifdef H5 -->
				<button type="primary" size="default" class="login-btn" @tap="login">
					登录
				</button>
			<!-- #endif -->
			<!-- #ifdef MP-WEIXIN -->
				<button type="primary" size="default" class="login-btn" @tap="login">
					<image src="/static/images/mine/wechat.png"></image>
					微信一键登录
				</button>
			<!-- #endif -->
			<view class="bottom-text" style="height: 30vh;">
				<view class="w-100 font-size-base text-color-assist">新用户登录即加入会员，享会员权益</view>
				<view class="w-100 row d-flex just-content-around align-items-center font-size-sm text-color-assist">
					<view class="grid">
						<image src="/static/images/mine/rhyl.png"></image>
						<view>入会有礼</view>
					</view>
					<view class="grid">
						<image src="/static/images/mine/jfdh.png"></image>
						<view>积分兑换</view>
					</view>
					<view class="grid">
						<image src="/static/images/mine/sjtq.png"></image>
						<view>升级特权</view>
					</view>
					<view class="grid">
						<image src="/static/images/mine/srtq.png"></image>
						<view>生日特权</view>
					</view>
					<view class="grid">
						<image src="/static/images/mine/nxbz.png"></image>
						<view>奈雪宝藏</view>
					</view>
				</view>
				<view class="text-color-primary">会员权益说明</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { mapActions,mapState } from 'vuex';
	import {userBalanceApi,getOrderListApi} from '@/service/index.js'

	export default {
		data() {
			return {
				// 登录信息
				userinfo:{
					phone:'18800000000',
					password:'123456'
				}
			}
		},
		computed:{
			...mapState('user',['isLogin'])
		},
		methods: {
			...mapActions('user',['userLogin']),
			// ...mapActions('goods',['getGoodsList','getCarouselAll','getShopList']),
			...mapActions('address',['getAddressList']),
			login(){
				this.userLogin(this.userinfo)
				if(this.isLogin){
					this.userBalance()
					this.getOrderList()
					// // 获取分类信息
					// this.getGoodsList({project_id:2})
					// // 获取轮播图
					// this.getCarouselAll({project_id:2})
					// // 获取所有商品
					// this.getShopList({project_id:2,limit:100})
					// // 获取地址列表
					this.getAddressList()
					uni.switchTab({
						url:'/pages/mine/mine'
					})
				}
			},
			// 查看余额
			async userBalance(){
				let res=await userBalanceApi()
				uni.setStorageSync('money',res.data.result.money)
			},
			// 获取订单列表
			async getOrderList(){
				let res=await getOrderListApi({limit:999})
				if(res.statusCode===200){
					uni.setStorageSync('orderList',res.data.result.rows)
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
.login{
	background-color: #f1f8fa;
	.intro {
			width: 100%;
			height: 60vh;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: space-evenly;
			font-size: 28rpx;
			color: #919293;
			
			image {
				width: 165rpx;
				height: 165rpx;
			}
			
			.tips {
				line-height: 72rpx;
				text-align: center;
			}
		}
		
		.bottom {
			height: 40vh;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			padding: 0 40rpx;
			
			.login-btn {
				width: 100%;
				border-radius: 50rem !important;
				display: flex;
				align-items: center;
				justify-content: center;
				padding: 10rpx 0;
				background-color: #ADB838;
				font-size: 28rpx;
				image {
					width: 36rpx;
					height: 30rpx;
					margin-right: 10rpx;
				}
			}
			.bottom-text{
				display: flex; 
				flex-direction: column;
				justify-content: space-evenly;
				align-items: center;
				.text-color-assist{
					color: #919293;
					font-size: 28rpx;
					text-align: center;
				}
				.row {
					display: flex;
					width: 100%;
					justify-content: space-between;
					.grid {
						width: 20%;
						image {
							width: 60rpx;
							height: 60rpx;
							margin-bottom: 10rpx;
						}
					}
				}
				.text-color-primary{
					color: #ADB838;
					font-size: 28rpx;
				}
			}
		}
}
</style>
